package oocl.ita.eordering.dao.impl;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.springframework.stereotype.Repository;

import oocl.ita.eordering.dao.ClientDao;
import oocl.ita.eordering.po.Client;

@Repository("cd")
public class ClientDaoImpl implements ClientDao {
	
	@PersistenceContext(name = "un")
	private EntityManager em;

	@SuppressWarnings("unchecked")
	@Override
	public Client findClient(Integer cId) {
		String jpql = "from Client where cId=:cId";
		List<Client> ls = em.createQuery(jpql).setParameter("cId", cId).getResultList();
		if (ls.isEmpty())
			return null;
		else
			return ls.get(0);
	}

}
